package com.koocloud.electroplatemanage.Exception;

import com.koocloud.electroplatemanage.common.pojo.ResponseTemplate;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

    //指定出现什么异常执行这个方法
    @ExceptionHandler(Exception.class)
    @ResponseBody //为了返回数据
    public ResponseTemplate error(Exception e) {
        e.printStackTrace();
        return ResponseTemplate.builder().code(0).message("出现未知错误！！请与管理员联系").build();
    }
}
